package com.zwj.design.creating.absfactory;

import com.zwj.design.creating.absfactory.app.Application;
import com.zwj.design.creating.absfactory.factories.GUIFactory;
import com.zwj.design.creating.absfactory.factories.MacOSFactory;
import com.zwj.design.creating.absfactory.factories.WindowsFactory;

/**
 * 抽象工厂模式
 * 模拟配置
 *
 * @author 张文接
 * @version 1.0
 * @createTime 2024/3/13 15:39
 */
public class Demo {
    /**
     * 模拟初始化配置
     *
     * @param systemType 系统类型：MacOS,Windows
     * @return 客户端
     */
    public static Application configureApplication(String systemType) {
        GUIFactory factory;
        if ("MacOS".equals(systemType)) {
            factory = new MacOSFactory();
        } else {
            factory = new WindowsFactory();
        }
        return new Application(factory);
    }

    public static void main(String[] args) {
        Application application = configureApplication("Windows");
        application.paint();
    }
}
